-
Notifications
You must be signed in to change notification settings - Fork 24.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(ivy): fix proliferation of provider overrides for modules #29571
Conversation
c5413e9
to
01c0da9
Compare
When an @NgModule is imported more than once in the testing module (for example it appears in the imports of more than one module, or if it's literally listed multiple times), then TestBed had a bug where the providers for the module would be overridden many times. This alone was problematic but would not break tests. However, the original value of the providers field of the ngInjectorDef was saved each time, and restored in the same order. Thus, if the provider array was [X], and overrides were applied twice, then the override array would become [X, X'] and then [X, X', X, X']. However, on the second override the state [X, X'] would be stored as original. The array would then be restored to [X] and then [X, X']. Each test, therefore, would continue to double the size of the providers array for the module, eventually exhausting the browser's memory. This commit adds a Set to track when overrides have been applied to a module and refrain from applying them more than once.
01c0da9
to
d76d678
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the quick fix!
…r#29571) When an @NgModule is imported more than once in the testing module (for example it appears in the imports of more than one module, or if it's literally listed multiple times), then TestBed had a bug where the providers for the module would be overridden many times. This alone was problematic but would not break tests. However, the original value of the providers field of the ngInjectorDef was saved each time, and restored in the same order. Thus, if the provider array was [X], and overrides were applied twice, then the override array would become [X, X'] and then [X, X', X, X']. However, on the second override the state [X, X'] would be stored as original. The array would then be restored to [X] and then [X, X']. Each test, therefore, would continue to double the size of the providers array for the module, eventually exhausting the browser's memory. This commit adds a Set to track when overrides have been applied to a module and refrain from applying them more than once. PR Close angular#29571
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
When an @NgModule is imported more than once in the testing module (for
example it appears in the imports of more than one module, or if it's
literally listed multiple times), then TestBed had a bug where the
providers for the module would be overridden many times.
This alone was problematic but would not break tests. However, the original
value of the providers field of the ngInjectorDef was saved each time, and
restored in the same order. Thus, if the provider array was [X], and
overrides were applied twice, then the override array would become
[X, X'] and then [X, X', X, X']. However, on the second override the state
[X, X'] would be stored as original. The array would then be restored to
[X] and then [X, X'].
Each test, therefore, would continue to double the size of the providers
array for the module, eventually exhausting the browser's memory.
This commit adds a Set to track when overrides have been applied to a module
and refrain from applying them more than once.